package com.czkj.hwz.decorate.adapter;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

import com.czkj.hwz.decorate.bean.Enterprise;
import com.czkj.hwz.decorate.fragment.FragmentFactory;
import com.czkj.hwz.decorate.fragment.IndexProcuctFragment;

import java.util.List;

/**
 * Created by janiszhang on 2016/6/10.
 */
//继承FragmentStatePagerAdapter
public class TestFragmentAdapter extends FragmentStatePagerAdapter {

    public static final String TAB_TAG = "@dream@";
    private int enterpriseid;
    private List<String> mTitles;
    private List<Enterprise> mEnterprises;
    public TestFragmentAdapter(FragmentManager fm, List<String> titles, List<Enterprise> mEnterprises) {
        super(fm);
        mTitles = titles;
        this.mEnterprises=mEnterprises;
    }

    @Override
    public android.support.v4.app.Fragment getItem(int position) {
        //初始化Fragment数据
//        ContentFragment fragment = new ContentFragment();
//
//        String[] title = mTitles.get(position).split(TAB_TAG);
//        fragment.setType(Integer.parseInt(title[1]));
//        fragment.setTitle(title[0]);
//        return fragment;
        enterpriseid=mEnterprises.get(position).getId();
//        BaseOperationCenterFragment baseOperationCenterFragment = FragmentFactory.createFragment(position, enterpriseid,"");
//        return baseOperationCenterFragment;
        IndexProcuctFragment indexProcuctFragment=FragmentFactory.createIndexProductFragment(position,enterpriseid,"",mTitles.get(position));
        return indexProcuctFragment;
    }

    @Override
    public int getCount() {
        return mTitles.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles.get(position).split(TAB_TAG)[0];
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
    }
}

